# coding=utf-8
import arcpy
path = r'D:\WorkData\20250712四川河流\0819处理'
arcpy.env.workspace = path
arcpy.env.overwriteOutput = True
spatial_ref = arcpy.SpatialReference(4326)
shp = r'D:\WorkData\20250712四川河流\0819处理\rivs1.shp'.decode('utf-8')
pointList = []
with arcpy.da.SearchCursor(shp, ['SHAPE@','name','rivId','level']) as cursor:
    for row in cursor:
        pointList.append([arcpy.PointGeometry(row[0].lastPoint),row[1],row[2],row[3]])
m_point = arcpy.CreateFeatureclass_management(r'D:\WorkData\20250712四川河流\0819处理', 'p.shp', 'POINT',spatial_reference=spatial_ref)
arcpy.AddField_management(m_point, 'name', 'TEXT')
arcpy.AddField_management(m_point, 'rivId', 'TEXT')
arcpy.AddField_management(m_point, 'level', 'TEXT')
arcpy.AddField_management(m_point, 'dis', 'TEXT')
arcpy.AddField_management(m_point, 'n_riv_name', 'TEXT')
arcpy.AddField_management(m_point, 'n_riv_id', 'TEXT')
arcpy.AddField_management(m_point, 'n_riv_lv', 'TEXT')
cs = arcpy.da.InsertCursor(m_point, ['SHAPE@','name','rivId','level'])
for Point in pointList:
    print Point
    cs.insertRow(Point)
del cs
